package com.ruoyi.web.controller.coronary;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.coronary.domain.CoronaryAppointment;
import com.ruoyi.coronary.service.ICoronaryAppointmentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 挂号信息Controller
 *
 * @author wky
 * @date 2024-02-06
 */
@RestController
@RequestMapping("/coronary/appointment")
@Tag(name = "【挂号信息】管理")
public class CoronaryAppointmentController extends BaseController
{
    @Autowired
    private ICoronaryAppointmentService coronaryAppointmentService;

    /**
     * 查询挂号信息列表
     */
    @Operation(summary = "查询挂号信息列表")
    @PreAuthorize("@ss.hasPermi('coronary:appointment:list')")
    @GetMapping("/list")
    public TableDataInfo list(CoronaryAppointment coronaryAppointment)
    {
        startPage();
        List<CoronaryAppointment> list = coronaryAppointmentService.selectCoronaryAppointmentList(coronaryAppointment);
        return getDataTable(list);
    }

    /**
     * 导出挂号信息列表
     */
    @Operation(summary = "导出挂号信息列表")
    @PreAuthorize("@ss.hasPermi('coronary:appointment:export')")
    @Log(title = "挂号信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CoronaryAppointment coronaryAppointment)
    {
        List<CoronaryAppointment> list = coronaryAppointmentService.selectCoronaryAppointmentList(coronaryAppointment);
        ExcelUtil<CoronaryAppointment> util = new ExcelUtil<CoronaryAppointment>(CoronaryAppointment.class);
        util.exportExcel(response, list, "挂号信息数据");
    }

    /**
     * 获取挂号信息详细信息
     */
    @Operation(summary = "获取挂号信息详细信息")
    @PreAuthorize("@ss.hasPermi('coronary:appointment:query')")
    @GetMapping(value = "/{appointmentId}")
    public AjaxResult getInfo(@PathVariable("appointmentId") Long appointmentId)
    {
        return success(coronaryAppointmentService.selectCoronaryAppointmentByAppointmentId(appointmentId));
    }

    /**
     * 新增挂号信息
     */
    @Operation(summary = "新增挂号信息")
    @PreAuthorize("@ss.hasPermi('coronary:appointment:add')")
    @Log(title = "挂号信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CoronaryAppointment coronaryAppointment)
    {
        return toAjax(coronaryAppointmentService.insertCoronaryAppointment(coronaryAppointment));
    }

    /**
     * 修改挂号信息
     */
    @Operation(summary = "修改挂号信息")
    @PreAuthorize("@ss.hasPermi('coronary:appointment:edit')")
    @Log(title = "挂号信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CoronaryAppointment coronaryAppointment)
    {
        return toAjax(coronaryAppointmentService.updateCoronaryAppointment(coronaryAppointment));
    }

    /**
     * 删除挂号信息
     */
    @Operation(summary = "删除挂号信息")
    @PreAuthorize("@ss.hasPermi('coronary:appointment:remove')")
    @Log(title = "挂号信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{appointmentIds}")
    public AjaxResult remove(@PathVariable( name = "appointmentIds" ) Long[] appointmentIds)
    {
        return toAjax(coronaryAppointmentService.deleteCoronaryAppointmentByAppointmentIds(appointmentIds));
    }
}
